package com.itheima;

import java.util.Scanner;

//编写一个用于判断是否是素数的程序，输入一个数，判断这个数是否为素数并输出。
public class FuncDemo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Please input a number:");
        int x = sc.nextInt();
        if (isPrime(x))
            System.out.println(x + " is a prime number");
        else
            System.out.println(x + " is not a prime number");
    }

    public static boolean isPrime(int x) {
        if (x < 2)
            return false;

        for (int i = 2; i <= x / i; i++) {
            if (x % i == 0)
                return false;

        }
        return true;

    }
}